import axios from "axios";

// Add a request interceptor
let axiosins = axios.interceptors.request.use(
  function(config) {
    let logintoken = sessionStorage.getItem("logintoken");
    // Do something before request is sent
    if (logintoken) {
      config.headers.Authorization = logintoken;
    }
    return config;
  },
  function(error) {
    // Do something with request error
    return Promise.reject(error);
  }
);

export default {
  login(data) {
    return axios.post("/api/login", data);
  },
  logout() {
    axios.interceptors.request.eject(axiosins);
  },
  getUserProgress() {
    return axios.get("/api/getUserProgress");
  }
};
